<?php
Class PTfacetModel extends CI_Model {
	function _construct()
	{
		parent::_construct();
	}
	
	function insertPTFacet($ptdomainid,$facetke,$nilaifacet,$levelfacet)
	{
//		ptfacetid,ptdomainid,facetke, nilaifacet, levelfacet
		$data = array(
			'PTDOMAINID' => $ptdomainid,
			'FACETKE' => $facetke,
			'NILAIFACET' => $nilaifacet,
			'LEVELFACET' => $levelfacet
			);
		$this->db->insert('ptfacet', $data);
			
	}
	
	function getPTFacet($domain) {
		$sql = "select FACETKE, NILAIFACET, LEVELFACET from ptfacet where PTDOMAINID = $domain  order by FACETKE ASC";
		$data = $this->db->query($sql);
		return $data;
	}
	
//	function insertPTFacet($ptfacetid,$ptdomainid,$facetke,$nilaifacet,$levelfacet)
//	{
////		ptfacetid,ptdomainid,facetke, nilaifacet, levelfacet
//		$data = array(
//			'PTFACETID' => $ptfacetid,
//			'PTDOMAINID' => $ptdomainid,
//			'FACETKE' => $facetke,
//			'NILAIFACET' => $nilaifacet,
//			'LEVELFACET' => $levelfacet
//			);
//		$this->db->insert('ptfacet', $data);
//			
//	}
	function getLastFacetid()
	{
		$sql = "SELECT MAX(ptfacetid) AS maxid FROM ptfacet";
		$hasil = $this->db->query($sql);
		$max = $hasil->row();
		return $max->maxid;
	}
	
	function select_facet($id_facet)
    {
    	$data = $this->db->query("select penjelasan_facet,nama_facet from penjelasan_facet where id_facet = '".$id_facet."'");
        return $data;
    }
}
?>